package com.lxh.flyweight;

import java.util.HashMap;

/**
 * Create by lxh on 2020/2/16
 */
public class ShapeFactory {

    private static HashMap<String, Shape> circleMap = new HashMap<>();

    public static Shape getCircle(String color) {
        Circle circle = (Circle) circleMap.get(color);

        if (circle == null) {
            circle = new Circle(color);
            circleMap.put(color, circle);
            System.out.println("创建圆的颜色为" + color);
        }
        return circle;

    }
}
